package ${package.Controller};

import tds.study.payment.pojo.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;

import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import ${cfg.queryPachage}.${entity}Query;
import ${cfg.pageVoPackage}.${entity}Vo;
import ${cfg.basePojoPackage}.dto.DeleteDto;
import ${cfg.addDtoPackage}.${entity}AddDto;
import ${cfg.updateDtoPackage}.${entity}UpdateDto;
import ${cfg.basePojoPackage}.vo.PageVo;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@Api(value = "${table.comment!}接口", tags = "${table.comment!}接口")
@ApiSupport(order=1)
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

   @Autowired
   private ${table.serviceName} ${entity?uncap_first}Service;

   <#if cfg.needSelectPage>
   @ApiOperation(value = "分页查询${table.comment!}",notes="分页查询${table.comment!}")
   @ApiOperationSupport(order = 1, author = "${author}")
   @PostMapping("/queryPage")
   public Result<PageVo<${entity}Vo>> queryPage(@ApiParam @RequestBody ${entity}Query query)  {
      return Result.success(${entity?uncap_first}Service.queryPage(query));
   }
   </#if>

   <#if cfg.needAdd>
   @ApiOperation(value = "新增${table.comment!}",notes="新增${table.comment!}")
   @ApiOperationSupport(order = 2, author = "${author}")
   @PostMapping("/add")
   public Result add(@ApiParam @RequestBody @Validated ${entity}AddDto addDto)  {
      ${entity?uncap_first}Service.save(addDto);
      return Result.success();
   }
   </#if>

   <#if cfg.needUpdate>
   @ApiOperation(value = "修改${table.comment!}",notes="修改${table.comment!}")
   @ApiOperationSupport(order = 3, author = "${author}")
   @PostMapping("/update")
   public Result update(@ApiParam @RequestBody @Validated ${entity}UpdateDto updateDto)  {
      ${entity?uncap_first}Service.update(updateDto);
      return Result.success();
   }
   </#if>

   <#if cfg.needDelete>
   @ApiOperation(value = "删除多个${table.comment!}",notes="删除多个${table.comment!}")
   @ApiOperationSupport(order = 4, author = "${author}")
   @PostMapping("/deleteBatch")
   public Result deleteBatch(@ApiParam @RequestBody @Validated DeleteDto deleteDto)  {
      ${entity?uncap_first}Service.delete(deleteDto);
      return Result.success();
   }
   </#if>
}
</#if>
